package com.gitee.wsl.doc.sample.opml.bean

import kotlinx.serialization.Serializable

/**
 * Metadata of the OPML feed. A `<head>` contains zero or more optional elements.
 */
@Serializable
data class Head(
    /**
     * The title of the document
     *
     * @return [String] or `null` if not set
     */
    val title: String? = null,
    /**
     * A date-time, indicating when the document was created (RFC 822 date)
     *
     * @return [String] or `null` if not set
     */
    val dateCreated: String? = null,
    /**
     * A date-time, indicating when the document was last modified (RFC 822 date)
     *
     * @return [String] or `null` if not set
     */
    val dateModified: String? = null,
    /**
     * The owner of the document
     *
     * @return [String] or `null` if not set
     */
    val ownerName: String? = null,
    /**
     * The email address of the owner of the document
     *
     * @return [String] or `null` if not set
     */
    val ownerEmail: String? = null,
    /**
     * The http address of a web page that contains information that allows a human reader to communicate with the
     * author of the document via email or other means. It also may be used to identify the author. No two authors have
     * the same ownerId.
     *
     * @return [String] or `null` if not set
     */
    val ownerId: String? = null,
    /**
     * The http address of documentation for the format used in the OPML file.It's probably a pointer to this page for
     * people who might stumble across the file on a web server 25 years from now and wonder what it is.
     *
     * @return [String] or `null` if not set
     */
    val docs: String? = null,
    /**
     * A comma-separated list of line numbers that are expanded. The line numbers in the list tell you which headlines
     * to expand. The order is important. For each element in the list, X, starting at the first summit, navigate
     * flatdown X times and expand. Repeat for each element in the list.
     *
     * @return mutable [List], never `null`
     */
    var expansionState: List<Int>? = null,

    /**
     * Line of the outline is displayed on the top line of the window. This number is calculated with the expansion
     * state already applied.
     *
     * @return [Integer] or `null` if not set
     */
    val vertScrollState: Int? = null,

    /**
     * The pixel location of the top edge of the window
     *
     * @return [Integer] or `null` if not set
     */
    val windowTop: Int? = null,

    /**
     * The pixel location of the left edge of the window
     *
     * @return [Integer] or `null` if not set
     */
    val windowLeft: Int? = null,

    /**
     * The pixel location of the bottom edge of the window
     *
     * @return [Integer] or `null` if not set
     */
    val windowBottom: Int? = null,

    /**
     * The pixel location of the right edge of the window
     *
     * @return [Integer] or `null` if not set
     */
    val windowRight: Int? = null,
)  {

    val expansionStateString: String
        /**
         * @return serialized form of expansionState element
         * @see .getExpansionState
         */
        get() {
            val sb = StringBuilder()
            for (i in expansionState!!.indices) {
                if (i > 0) {
                    sb.append(", ")
                }
                sb.append(expansionState!![i])
            }
            return sb.toString()
        }

    override fun toString(): String {
        return StringBuilder()
            .append("Head [")
            .append(System.lineSeparator())
            .append("\ttitle=")
            .append(title)
            .append(System.lineSeparator())
            .append("\tdateCreated=")
            .append(dateCreated)
            .append(System.lineSeparator())
            .append("\tdateModified=")
            .append(dateModified)
            .append(System.lineSeparator())
            .append("\townerName=")
            .append(ownerName)
            .append(System.lineSeparator())
            .append("\townerEmail=")
            .append(ownerEmail)
            .append(System.lineSeparator())
            .append("\townerId=")
            .append(ownerId)
            .append(System.lineSeparator())
            .append("\tdocs=")
            .append(docs)
            .append(System.lineSeparator())
            .append("\texpansionState=")
            .append(expansionState)
            .append(System.lineSeparator())
            .append("\tvertScrollState=")
            .append(vertScrollState)
            .append(System.lineSeparator())
            .append("\twindowTop=")
            .append(windowTop)
            .append(System.lineSeparator())
            .append("\twindowLeft=")
            .append(windowLeft)
            .append(System.lineSeparator())
            .append("\twindowBottom=")
            .append(windowBottom)
            .append(System.lineSeparator())
            .append("\twindowRight=")
            .append(windowRight)
            .append("]")
            .toString()
    }




}